<!DOCTYPE html>
<!-- saved from url=(0046)https://www.cnblogs.com/a00ium/p/14128887.html -->
<html lang="zh-cn" style="--olcb-folder-code-block-max-height: 80vh; --cnb-code-bg: rgb(245, 245, 245); --cnb-code-font-size: 12px; --cnb-code-color: rgb(68, 68, 68);"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="referrer" content="origin-when-cross-origin">
    
    <meta name="description" content="本教程提供了使用协议缓冲区的基本Python程序员介绍。通过创建一个简单的示例应用程序，它向您展示了如何 在.proto文件中定义消息格式。 使用协议缓冲区编译器。 使用Python协议缓冲区API写入和读取消息。 这不是在Python中使用协议缓冲区的全面指南。有关更多详细的参考信息，请参阅《协议">
    <meta property="og:description" content="本教程提供了使用协议缓冲区的基本Python程序员介绍。通过创建一个简单的示例应用程序，它向您展示了如何 在.proto文件中定义消息格式。 使用协议缓冲区编译器。 使用Python协议缓冲区API写入和读取消息。 这不是在Python中使用协议缓冲区的全面指南。有关更多详细的参考信息，请参阅《协议">
    <meta http-equiv="Cache-Control" content="no-transform">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>协议缓冲区基础：Python - DaisyLinux - 博客园</title>
    <link rel="canonical" href="https://www.cnblogs.com/a00ium/p/14128887.html">
    <link rel="shortcut icon" id="favicon" href="https://assets.cnblogs.com/favicon.svg?v=2" type="image/svg+xml">
    
    <style>#home :not(.cnblogs_code):not(.cnblogs_Highlighter)>pre:not([highlighted]):not([class*="brush:"]) code:not(.hljs), :not(.cnblogs_code):not(.cnblogs_Highlighter)>pre:not([highlighted]):not([class*="brush:"]) code:not(.hljs) {background: rgb(245, 245, 245);
        padding: 12px;
        border: 0.8px solid rgb(204, 204, 204);
        border-radius: 3px;
        border-color: transparent;
        color: rgb(68, 68, 68);
        font-family: "Courier New", sans-serif;
        font-size: 12px</style><link rel="stylesheet" href="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/blog-common.min.css">
    

    <link id="MainCss" rel="stylesheet" href="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/bundle-bluesky.min.css">
        <link id="highlighter-theme-cnblogs" type="text/css" rel="stylesheet" href="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/cnblogs.css">
    
    
    <link id="mobile-style" media="only screen and (max-width: 767px)" type="text/css" rel="stylesheet" href="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/bundle-bluesky-mobile.min.css">
    
    <link type="application/rss+xml" rel="alternate" href="https://www.cnblogs.com/a00ium/rss">
    <link type="application/rsd+xml" rel="EditURI" href="https://www.cnblogs.com/a00ium/rsd.xml">
    <link type="application/wlwmanifest+xml" rel="wlwmanifest" href="https://www.cnblogs.com/a00ium/wlwmanifest.xml">
    <script>
        var currentBlogId = 233489;
        var currentBlogApp = 'a00ium';
        var isLogined = false;
        var isBlogOwner = false;
        var skinName = 'BlueSky';
        var visitorUserId = '';
        var hasCustomScript = false;
        window.cb_enable_mathjax = false;
        window.mathEngine = 0;
        window.codeHighlightEngine = 1;
        window.enableCodeLineNumber = false;
        window.codeHighlightTheme = 'cnblogs';
        window.darkModeCodeHighlightTheme = 'vs2015';
        window.isDarkCodeHighlightTheme = false;
        window.isDarkModeCodeHighlightThemeDark = true;
        window.isDisableCodeHighlighter = false;
        window.enableCodeThemeTypeFollowSystem = false;
        window.enableMacStyleCodeBlock = false;
    </script>
        <script>
            window.currentPostId = 14128887;
            window.currentPostDateAdded = '2020-12-13 16:03';
        </script>
    <script src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/jquery-3.3.1.min.js"></script>
    <script src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/blog-common.min.js"></script><style>.medium-zoom-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  opacity: 0;
  transition: opacity 300ms;
  will-change: opacity;
}

.medium-zoom--opened .medium-zoom-overlay {
  cursor: pointer;
  cursor: zoom-out;
  opacity: 1;
}

.medium-zoom-image {
  cursor: pointer;
  cursor: zoom-in;
  /*
    The `transition` is marked as "!important" for the animation to happen
    even though it's overriden by another inline `transition` style attribute.

    This is problematic with frameworks that generate inline styles on their
    images (e.g. Gatsby).

    See https://github.com/francoischalifour/medium-zoom/issues/110
   */
  transition: transform 300ms cubic-bezier(0.2, 0, 0.2, 1) !important;
}

.medium-zoom-image--hidden {
  visibility: hidden;
}

.medium-zoom-image--opened {
  position: relative;
  cursor: pointer;
  cursor: zoom-out;
  will-change: transform;
}
</style><script id="hljs-script" src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/highlight.min.js" type="text/javascript" async=""></script>
    
<meta property="og:image" content="https://assets.cnblogs.com/logo_square.png"></head>
<body class="skin-bluesky has-navbar">
    <a name="top"></a>
    <div id="top_nav" class="navbar forpc">
        <nav id="nav_main" class="navbar-main">
            <ul id="nav_left" class="navbar-list navbar-left">
                <li class="navbar-branding">
                    <a href="https://www.cnblogs.com/" title="开发者的网上家园" role="banner">
                        <img src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/logo.svg" alt="博客园Logo">
                    </a>
                </li>
                <li><a href="https://cnblogs.vip/">会员</a></li>
                <li><a href="https://www.cnblogs.com/cmt/articles/18197617">众包</a></li>
                <li>
                    <a href="https://news.cnblogs.com/" onclick="countClicks(&#39;nav&#39;, &#39;skin-navbar-news&#39;)">新闻</a>
                </li>
                <li>
                    <a href="https://q.cnblogs.com/" onclick="countClicks(&#39;nav&#39;, &#39;skin-navbar-q&#39;)">博问</a>
                </li>
                <li>
                    <a href="https://ing.cnblogs.com/" onclick="countClicks(&#39;nav&#39;, &#39;skin-navbar-ing&#39;)">闪存</a>
                </li>
                <li><a href="https://market.cnblogs.com/" target="_blank">云市场</a></li>
            </ul>
            <ul id="nav_right" class="navbar-list navbar-right">
                <li>
                    <form id="zzk_search" class="navbar-search dropdown" action="https://zzk.cnblogs.com/s" method="get" role="search">
                        <input name="w" id="zzk_search_input" placeholder="代码改变世界" type="search" tabindex="3" autocomplete="off">
                        <button id="zzk_search_button" onclick="window.navbarSearchManager.triggerActiveOption()">
                            <img id="search_icon" class="focus-hidden" src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/search.svg" alt="搜索">
                            <img class="hidden focus-visible" src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/enter.svg" alt="搜索">
                        </button>
                        <ul id="navbar_search_options" class="dropdown-menu quick-search-menu">
                            <li tabindex="0" class="active" onclick="zzkSearch(event, document.getElementById(&#39;zzk_search_input&#39;).value)">
                                <div class="keyword-wrapper">
                                    <img src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/search.svg" alt="搜索">
                                    <div class="keyword"></div>
                                </div>
                                <span class="search-area">所有博客</span>
                            </li>
                                    <li tabindex="1" onclick="zzkBlogSearch(event, &#39;a00ium&#39;, document.getElementById(&#39;zzk_search_input&#39;).value)">
                                        <div class="keyword-wrapper">
                                            <img src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/search.svg" alt="搜索">
                                            <div class="keyword"></div>
                                        </div>
                                        <span class="search-area">当前博客</span>
                                    </li>
                        </ul>
                    </form>
                </li>
                <li id="navbar_login_status" class="navbar-list">
                    <a class="navbar-user-info navbar-blog" href="https://i.cnblogs.com/EditPosts.aspx?opt=1" alt="写随笔" title="写随笔" style="display: none;">
                        <img id="new_post_icon" class="navbar-icon" src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/newpost.svg" alt="写随笔">
                    </a>
                    <a id="navblog-myblog-icon" class="navbar-user-info navbar-blog" href="https://passport.cnblogs.com/GetBlogApplyStatus.aspx" alt="我的博客" title="我的博客" style="display: none;">
                        <img id="myblog_icon" class="navbar-icon" src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/myblog.svg" alt="我的博客">
                    </a>
                    <a class="navbar-user-info navbar-message navbar-icon-wrapper" href="https://msg.cnblogs.com/" alt="短消息" title="短消息" style="display: none;">
                        <img id="msg_icon" class="navbar-icon" src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/message.svg" alt="短消息">
                        <span id="msg_count" style="display: none"></span>
                    </a>
                    <a id="navbar_lite_mode_indicator" data-current-page="blog" style="display: none" href="javascript:void(0)" alt="简洁模式" title="简洁模式启用，您在访问他人博客时会使用简洁款皮肤展示">
                        <img class="navbar-icon" src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/lite-mode-on.svg" alt="简洁模式">
                    </a>
                    <div id="user_info" class="navbar-user-info dropdown" style="display: none;">
                        <a class="dropdown-button" href="https://home.cnblogs.com/">
                            <img id="user_icon" class="navbar-avatar" src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/avatar-default.svg" alt="用户头像">
                        </a>
                        <div class="dropdown-menu">
                            <a id="navblog-myblog-text" href="https://passport.cnblogs.com/GetBlogApplyStatus.aspx">我的博客</a>
                            <a href="https://home.cnblogs.com/">我的园子</a>
                            <a href="https://account.cnblogs.com/settings/account">账号设置</a>
                            <a href="javascript:void(0)" id="navbar_lite_mode_toggle" title="简洁模式会使用简洁款皮肤显示所有博客">
    简洁模式 <img id="navbar_lite_mode_on" src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/lite-mode-check.svg" class="hide" style="display: none;"><span id="navbar_lite_mode_spinner" class="hide">...</span>
</a>
                            <a href="javascript:void(0)" onclick="account.logout();">退出登录</a>
                        </div>
                    </div>
                    <a class="navbar-anonymous" href="https://account.cnblogs.com/signup" style="display: inline;">注册</a>
                    <a class="navbar-anonymous" href="javascript:void(0);" onclick="account.login()" style="display: inline;">登录</a>
                </li>
            </ul>
        </nav>
    </div>

    

    <!--done-->
<div id="home">
<div id="header">
	<div id="blogTitle">
        <a id="lnkBlogLogo" href="https://www.cnblogs.com/a00ium/"><img id="blogLogo" src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/logo.gif" alt="返回主页"></a>		
		
<!--done-->
<h1><a id="Header1_HeaderTitle" class="headermaintitle HeaderMainTitle" href="https://www.cnblogs.com/a00ium">DaisyLinux</a>
</h1>
<h2></h2>




		
	</div><!--end: blogTitle 博客的标题和副标题 -->
	<div id="navigator">
		
<ul id="navList">
<li><a id="blog_nav_sitehome" class="menu" href="https://www.cnblogs.com/">
博客园</a>
</li>
<li>
<a id="blog_nav_myhome" class="menu" href="https://www.cnblogs.com/a00ium/">
首页</a>
</li>
<li>

<a id="blog_nav_newpost" class="menu" href="https://i.cnblogs.com/EditPosts.aspx?opt=1">
新随笔</a>
</li>
<li>
<a id="blog_nav_contact" class="menu" href="https://msg.cnblogs.com/send/DaisyLinux">
联系</a></li>
<li>
<a id="blog_nav_rss" class="menu" href="javascript:void(0)" data-rss="https://www.cnblogs.com/a00ium/rss/">
订阅</a>
<!--<partial name="./Shared/_XmlLink.cshtml" model="Model" /></li>--></li>
<li>
<a id="blog_nav_admin" class="menu" href="https://i.cnblogs.com/">
管理</a>
</li>
</ul>


		<div class="blogStats">
			<span id="stats_post_count">随笔 - 494&nbsp; </span>
<span id="stats_article_count">文章 - 1&nbsp; </span>
<span id="stats-comment_count">评论 - 17&nbsp; </span>
<span id="stats-total-view-count">阅读 - 
<span title="总阅读数: 651886">
65万</span></span>

		</div><!--end: blogStats -->
	</div><!--end: navigator 博客导航栏 -->
</div><!--end: header 头部 -->
<div id="main">
	<div id="mainContent">
	<div class="forFlow">
		<div id="post_detail">
    <!--done-->
    <div id="topics">
        <div class="post">
            <h1 class="postTitle">
                <a id="cb_post_title_url" class="postTitle2 vertical-middle" href="https://www.cnblogs.com/a00ium/p/14128887.html" title="发布于 2020-12-13 16:03">
    <span role="heading" aria-level="2">协议缓冲区基础：Python</span>
    

</a><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button>

            </h1>
            <div class="clear"></div>
            <div class="postBody">
                <div id="cnblogs_post_body" class="blogpost-body blogpost-body-html">
<p><span><span>本教程提供了使用协议缓冲区的基本Python程序员介绍。</span><span>通过创建一个简单的示例应用程序，它向您展示了如何</span></span></p>
<ul>
<li><span>在</span><code dir="ltr">.proto</code><span><span>文件中</span><span>定义消息格式</span><span>。</span></span></li>
<li><span>使用协议缓冲区编译器。</span></li>
<li><span>使用Python协议缓冲区API写入和读取消息。</span></li>
</ul>
<p><span><span>这不是在Python中使用协议缓冲区的全面指南。</span><span>有关更多详细的参考信息，请参阅《</span></span><a href="https://developers.google.com/protocol-buffers/docs/proto" rel="noopener">协议缓冲区语言指南》</a><span>，《</span><a href="https://googleapis.dev/python/protobuf/latest/" rel="noopener">Python API参考》</a><span>，《</span><a href="https://developers.google.com/protocol-buffers/docs/reference/python-generated" rel="noopener">Python生成的代码指南》</a><span>和《</span><a href="https://developers.google.com/protocol-buffers/docs/encoding" rel="noopener">编码参考》</a><span>。</span></p>
<h2 id="why-use-protocol-buffers" data-text="Why Use Protocol Buffers?"><span>为什么要使用协议缓冲区？</span><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p><span><span>我们将使用的示例是一个非常简单的“地址簿”应用程序，它可以在文件中读取和写入人们的联系方式。</span><span>通讯录中的每个人都有一个姓名，一个ID，一个电子邮件地址和一个联系电话。</span></span></p>
<p><span><span>您如何像这样序列化和检索结构化数据？</span><span>有几种方法可以解决此问题：</span></span></p>
<ul>
<li><span><span>使用Python酸洗。</span><span>这是默认方法，因为它已内置在该语言中，但是它不能很好地处理模式演变，如果需要与用C ++或Java编写的应用程序共享数据，也不能很好地工作。</span></span></li>
<li><span><span>您可以发明一种将数据项编码为单个字符串的临时方法，例如将4个整数编码为“ 12：3：-23：67”。</span><span>尽管确实需要编写一次性编码和解析代码，但是这是一种简单且灵活的方法，而且解析带来的运行时成本很小。</span><span>这对于编码非常简单的数据最有效。</span></span></li>
<li><span><span>将数据序列化为XML。</span><span>由于XML是人类（一种）可读的，并且存在用于多种语言的绑定库，因此这种方法可能非常有吸引力。</span><span>如果要与其他应用程序/项目共享数据，这可能是一个不错的选择。</span><span>但是，众所周知，XML占用大量空间，对它进行编码/解码会给应用程序带来巨大的性能损失。</span><span>同样，导航XML DOM树比通常导航类中的简单字段要复杂得多。</span></span></li>
</ul>
<p><span><span>协议缓冲区是解决此问题的灵活，高效，自动化的解决方案。</span><span>使用协议缓冲区，您可以编写</span></span><code dir="ltr">.proto</code><span><span>要存储的数据结构</span><span>的</span><span>描述。</span><span>由此，协议缓冲区编译器创建了一个类，该类以有效的二进制格式实现协议缓冲区数据的自动编码和解析。</span><span>生成的类为构成协议缓冲区的字段提供了获取器和设置器，并以协议为单位来处理读写协议缓冲区的细节。</span><span>重要的是，协议缓冲区格式支持以某种方式扩展格式的思想，以使代码仍可以读取以旧格式编码的数据。</span></span></p>
<h2 id="where-to-find-the-example-code" data-text="Where to Find the Example Code"><span>在哪里可以找到示例代码</span><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p><span>示例代码包含在源代码包中的“ examples”目录下。&nbsp;</span><a href="https://developers.google.com/protocol-buffers/docs/downloads" rel="noopener">在这里下载。</a></p>
<h2 id="defining-your-protocol-format" data-text="Defining Your Protocol Format"><span>定义协议格式</span><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p><span>要创建地址簿应用程序，您需要从</span><code dir="ltr">.proto</code><span><span>文件</span><span>开始</span><span>。</span></span><code dir="ltr">.proto</code><span><span>文件中</span><span>的定义</span><span>很简单：您</span><span>为要序列化的每个数据结构</span><span>添加一条</span></span><em>消息</em><span><span>，然后为消息中的每个字段指定名称和类型。</span><span>这是</span></span><code dir="ltr">.proto</code><span><span>定义您的消息</span><span>的</span><span>文件</span></span><code dir="ltr">addressbook.proto</code><span>。</span></p>
<div class="cnblogs_Highlighter sh-gutter">
<div><div id="highlighter_912329" class="syntaxhighlighter  csharp"><div class="toolbar"><span><a href="https://www.cnblogs.com/a00ium/p/14128887.html#" class="toolbar_item command_help help">?</a></span></div><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div><div class="line number16 index15 alt1">16</div><div class="line number17 index16 alt2">17</div><div class="line number18 index17 alt1">18</div><div class="line number19 index18 alt2">19</div><div class="line number20 index19 alt1">20</div><div class="line number21 index20 alt2">21</div><div class="line number22 index21 alt1">22</div><div class="line number23 index22 alt2">23</div><div class="line number24 index23 alt1">24</div><div class="line number25 index24 alt2">25</div><div class="line number26 index25 alt1">26</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp plain">syntax = </code><code class="csharp string">"proto2"</code><code class="csharp plain">;</code></div><div class="line number2 index1 alt1">&nbsp;</div><div class="line number3 index2 alt2"><code class="csharp plain">package tutorial;</code></div><div class="line number4 index3 alt1">&nbsp;</div><div class="line number5 index4 alt2"><code class="csharp plain">message Person {</code></div><div class="line number6 index5 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">optional </code><code class="csharp keyword">string</code> <code class="csharp plain">name = 1;</code></div><div class="line number7 index6 alt2"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">optional int32 id = 2;</code></div><div class="line number8 index7 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">optional </code><code class="csharp keyword">string</code> <code class="csharp plain">email = 3;</code></div><div class="line number9 index8 alt2">&nbsp;</div><div class="line number10 index9 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp keyword">enum</code> <code class="csharp plain">PhoneType {</code></div><div class="line number11 index10 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">MOBILE = 0;</code></div><div class="line number12 index11 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">HOME = 1;</code></div><div class="line number13 index12 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">WORK = 2;</code></div><div class="line number14 index13 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">}</code></div><div class="line number15 index14 alt2">&nbsp;</div><div class="line number16 index15 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">message PhoneNumber {</code></div><div class="line number17 index16 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">optional </code><code class="csharp keyword">string</code> <code class="csharp plain">number = 1;</code></div><div class="line number18 index17 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">optional PhoneType type = 2 [</code><code class="csharp keyword">default</code> <code class="csharp plain">= HOME];</code></div><div class="line number19 index18 alt2"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">}</code></div><div class="line number20 index19 alt1">&nbsp;</div><div class="line number21 index20 alt2"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">repeated PhoneNumber phones = 4;</code></div><div class="line number22 index21 alt1"><code class="csharp plain">}</code></div><div class="line number23 index22 alt2">&nbsp;</div><div class="line number24 index23 alt1"><code class="csharp plain">message AddressBook {</code></div><div class="line number25 index24 alt2"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">repeated Person people = 1;</code></div><div class="line number26 index25 alt1"><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div>
</div>
<p>　　</p>
<p><span><span>如您所见，语法类似于C ++或Java。</span><span>让我们浏览文件的每个部分，看看它的作用。</span></span></p>
<p><span>该</span><code dir="ltr">.proto</code><span><span>文件以程序包声明开头，这有助于防止不同项目之间的命名冲突。</span><span>在Python中，包通常由目录结构决定，因此</span></span><code dir="ltr">package</code><span>您在</span><code dir="ltr">.proto</code><span><span>文件中</span><span>定义的包</span><span>不会对生成的代码产生影响。</span><span>但是，您仍然应该声明一个以避免在协议缓冲区名称空间以及非Python语言中的名称冲突。</span></span></p>
<p><span><span>接下来，您将拥有消息定义。</span><span>消息只是包含一组类型字段的汇总。</span><span>许多标准的简单数据类型都可以作为字段类型，包括</span></span><code dir="ltr">bool</code><span>，</span><code dir="ltr">int32</code><span>，</span><code dir="ltr">float</code><span>，</span><code dir="ltr">double</code><span>，和</span><code dir="ltr">string</code><span><span>。</span><span>您还可以通过使用其他消息类型作为字段类型来为消息添加更多结构-在上述示例中，</span></span><code dir="ltr">Person</code><span>消息包含</span><code dir="ltr">PhoneNumber</code><span>消息，而</span><code dir="ltr">AddressBook</code><span>消息包含</span><code dir="ltr">Person</code><span><span>消息。</span><span>您甚至可以定义嵌套在其他消息内的消息类型-如您所见，该</span></span><code dir="ltr">PhoneNumber</code><span>类型在内部定义</span><code dir="ltr">Person</code><span>。</span><code dir="ltr">enum</code><span><span>如果您希望某个字段具有一个预定义的值列表之一，</span><span>也可以定义</span><span>类型-在这里您要指定电话号码可以是</span></span><code dir="ltr">MOBILE</code><span>，</span><code dir="ltr">HOME</code><span>或</span><code dir="ltr">WORK</code><span>。</span></p>
<p><span><span>每个元素上的“ = 1”，“ = 2”标记标识该字段在二进制编码中使用的唯一“标记”。</span><span>标签编号1至15与较高的编号相比，编码所需的字节减少了一个字节，因此，为了进行优化，您可以决定将这些标签用于常用或重复的元素，而将标签16和更高的标签用于较少使用的可选元素。</span><span>重复字段中的每个元素都需要重新编码标签号，因此重复字段是此优化的最佳候选者。</span></span></p>
<p><span>每个字段都必须使用以下修饰符之一进行注释：</span></p>
<ul>
<li><code dir="ltr">optional</code><span><span>：可能会或可能不会设置该字段。</span><span>如果未设置可选字段值，则使用默认值。</span><span>对于简单类型，您可以指定自己的默认值，就像</span></span><code dir="ltr">type</code><span><span>在示例中</span><span>为电话号码所做的那样</span><span>。</span><span>否则，将使用系统默认值：数字类型为零，字符串为空字符串，布尔值为false。</span><span>对于嵌入式消息，默认值始终是消息的“默认实例”或“原型”，没有设置任何字段。</span><span>调用访问器以获取未显式设置的可选（或必填）字段的值始终会返回该字段的默认值。</span></span></li>
<li><code dir="ltr">repeated</code><span><span>：该字段可以重复任意次（包括零次）。</span><span>重复值的顺序将保留在协议缓冲区中。</span><span>将重复字段视为动态大小的数组。</span></span></li>
<li><code dir="ltr">required</code><span><span>：必须提供该字段的值，否则该消息将被视为“未初始化”。</span><span>序列化未初始化的消息将引发异常。</span><span>解析未初始化的消息将失败。</span><span>除此之外，必填字段的行为与可选字段完全相同。</span></span></li>
</ul>
<p class="caution">永远是必需的<span>&nbsp;您将字段标记为时应非常小心</span><code dir="ltr">required</code><span><span>。</span><span>如果您希望停止写入或发送必填字段，则将字段更改为可选字段会很麻烦–老读者会认为没有该字段的邮件是不完整的，可能会无意中拒绝或丢弃它们。</span><span>您应该考虑为缓冲区编写特定于应用程序的自定义验证例程。</span><span>在Google内部，</span></span><code dir="ltr">required</code><span><span>强烈反对使用字段；</span><span>proto2语法中定义的大多数消息</span><span>仅</span><span>使用</span></span><code dir="ltr">optional</code><span>并且</span><code dir="ltr">repeated</code><span><span>。</span><span>（Proto3根本不支持</span></span><code dir="ltr">required</code><span>字段。）</span></p>
<p><span>您</span><code dir="ltr">.proto</code><span>可以在“</span><a href="https://developers.google.com/protocol-buffers/docs/proto" rel="noopener">协议缓冲区语言指南”中</a><span><span>找到有关编写</span><span>文件</span><span>的完整指南，</span><span>包括所有可能的字段类型</span><span>。</span><span>但是，不要去寻找类似于类继承的工具–协议缓冲区不能做到这一点。</span></span></p>
<h2 id="compiling-your-protocol-buffers" data-text="Compiling Your Protocol Buffers"><span>编译协议缓冲区</span><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p><span>既然有了</span><code dir="ltr">.proto</code><span>，接下来需要做的就是生成读取和写入</span><code dir="ltr">AddressBook</code><span>（以及因此</span><code dir="ltr">Person</code><span>和</span><code dir="ltr">PhoneNumber</code><span><span>）消息所需的类。</span><span>要做到这一点，你需要运行协议缓冲编译器</span></span><code dir="ltr">protoc</code><span>对您</span><code dir="ltr">.proto</code><span>：</span></p>
<ol>
<li><span>如果尚未安装编译器，请</span><a href="https://developers.google.com/protocol-buffers/docs/downloads" rel="noopener">下载软件包</a><span>并按照README中的说明进行操作。</span></li>
<li><span>现在运行编译器，指定源目录（应用程序的源代码所在的位置；如果不提供值，则使用当前目录），目标目录（您希望生成的代码进入的位置；通常与相同</span><code dir="ltr">$SRC_DIR</code><span>）以及通向您的道路</span><code dir="ltr">.proto</code><span><span>。</span><span>在这种情况下，您...：</span></span>
<div class="devsite-code-buttons-container">&nbsp;</div>
<div class="cnblogs_Highlighter sh-gutter">
<div><div id="highlighter_114001" class="syntaxhighlighter  csharp"><div class="toolbar"><span><a href="https://www.cnblogs.com/a00ium/p/14128887.html#" class="toolbar_item command_help help">?</a></span></div><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp plain">protoc -I=$SRC_DIR --python_out=$DST_DIR $SRC_DIR/addressbook.proto</code></div></div></td></tr></tbody></table></div></div>
</div>
<p>　　</p>
<span>因为您需要Python类，所以可以使用该</span><code dir="ltr">--python_out</code><span>选项–其他受支持的语言也提供了类似的选项。</span></li>
</ol>
<p><span>这将</span><code dir="ltr">addressbook_pb2.py</code><span><span>在您指定的目标目录中</span><span>生成</span><span>。</span></span></p>
<h2 id="the-protocol-buffer-api" data-text="The Protocol Buffer API"><span>协议缓冲区API</span><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p><span><span>与生成Java和C ++协议缓冲区代码时不同，Python协议缓冲区编译器不会直接为您生成数据访问代码。</span><span>相反（如您所见，您会看到</span></span><code dir="ltr">addressbook_pb2.py</code><span>它）为所有消息，枚举和字段以及一些神秘的空类生成特殊的描述符，每种消息类型一个：</span></p>
<div class="devsite-code-buttons-container">
<div class="cnblogs_Highlighter sh-gutter">
<div><div id="highlighter_528115" class="syntaxhighlighter  csharp"><div class="toolbar"><span><a href="https://www.cnblogs.com/a00ium/p/14128887.html#" class="toolbar_item command_help help">?</a></span></div><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp keyword">class</code> <code class="csharp plain">Person(message.Message):</code></div><div class="line number2 index1 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">__metaclass__ = reflection.GeneratedProtocolMessageType</code></div><div class="line number3 index2 alt2">&nbsp;</div><div class="line number4 index3 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp keyword">class</code> <code class="csharp plain">PhoneNumber(message.Message):</code></div><div class="line number5 index4 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">__metaclass__ = reflection.GeneratedProtocolMessageType</code></div><div class="line number6 index5 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">DESCRIPTOR = _PERSON_PHONENUMBER</code></div><div class="line number7 index6 alt2"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">DESCRIPTOR = _PERSON</code></div><div class="line number8 index7 alt1">&nbsp;</div><div class="line number9 index8 alt2"><code class="csharp keyword">class</code> <code class="csharp plain">AddressBook(message.Message):</code></div><div class="line number10 index9 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">__metaclass__ = reflection.GeneratedProtocolMessageType</code></div><div class="line number11 index10 alt2"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">DESCRIPTOR = _ADDRESSBOOK</code></div></div></td></tr></tbody></table></div></div>
</div>
<p>　　</p>
<p><span>每个班级的重要一行是</span><code dir="ltr">__metaclass__ = reflection.GeneratedProtocolMessageType</code><span><span>。</span><span>尽管Python元类如何工作的详细信息超出了本教程的范围，但是您可以将它们视为创建类的模板。</span><span>在加载时，</span></span><code dir="ltr">GeneratedProtocolMessageType</code><span><span>元类使用指定的描述符创建每种消息类型都需要使用的所有Python方法，并将它们添加到相关的类中。</span><span>然后，您可以在代码中使用完全填充的类。</span></span></p>
<p><span>所有这些的最终结果是，您可以像使用</span><code dir="ltr">Person</code><span>类一样将</span><code dir="ltr">Message</code><span><span>基类的</span><span>每个字段定义</span><span>为常规字段。</span><span>例如，您可以编写：</span></span></p>
<div class="devsite-code-buttons-container">&nbsp;</div>
</div>
<div class="devsite-code-buttons-container">
<div class="cnblogs_Highlighter sh-gutter">
<div><div id="highlighter_603146" class="syntaxhighlighter  csharp"><div class="toolbar"><span><a href="https://www.cnblogs.com/a00ium/p/14128887.html#" class="toolbar_item command_help help">?</a></span></div><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp plain">import addressbook_pb2</code></div><div class="line number2 index1 alt1"><code class="csharp plain">person = addressbook_pb2.Person()</code></div><div class="line number3 index2 alt2"><code class="csharp plain">person.id = 1234</code></div><div class="line number4 index3 alt1"><code class="csharp plain">person.name = </code><code class="csharp string">"John Doe"</code></div><div class="line number5 index4 alt2"><code class="csharp plain">person.email = </code><code class="csharp string">"jdoe@example.com"</code></div><div class="line number6 index5 alt1"><code class="csharp plain">phone = person.phones.add()</code></div><div class="line number7 index6 alt2"><code class="csharp plain">phone.number = </code><code class="csharp string">"555-4321"</code></div><div class="line number8 index7 alt1"><code class="csharp plain">phone.type = addressbook_pb2.Person.HOME</code></div></div></td></tr></tbody></table></div></div>
</div>
<p>　　</p>
<p><span><span>请注意，这些分配不只是向通用Python对象添加任意新字段。</span><span>如果您尝试分配</span></span><code dir="ltr">.proto</code><span><span>文件中</span><span>未定义的字段，</span></span><code dir="ltr">AttributeError</code><span><span>则会引发。</span><span>如果将字段分配给错误类型的值，</span></span><code dir="ltr">TypeError</code><span><span>则会引发a。</span><span>同样，在设置字段之前读取它的值将返回默认值。</span></span></p>
<div class="devsite-code-buttons-container">&nbsp;</div>
<div class="cnblogs_Highlighter sh-gutter">
<div><div id="highlighter_442401" class="syntaxhighlighter  csharp"><div class="toolbar"><span><a href="https://www.cnblogs.com/a00ium/p/14128887.html#" class="toolbar_item command_help help">?</a></span></div><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp plain">person.no_such_field = 1&nbsp; # raises AttributeError</code></div><div class="line number2 index1 alt1"><code class="csharp plain">person.id = </code><code class="csharp string">"1234"</code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <code class="csharp plain"># raises TypeError</code></div></div></td></tr></tbody></table></div></div>
</div>
<p>　</p>
<p><span>有关协议编译器为任何特定字段定义生成的成员的确切信息，请参见</span><a href="https://developers.google.com/protocol-buffers/docs/reference/python-generated" rel="noopener">Python生成的代码参考</a><span>。</span></p>
<h3 id="enums" data-text="Enums"><span>枚举</span><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p><span><span>元类将枚举扩展为具有整数值的一组符号常量。</span><span>因此，例如，常数</span></span><code dir="ltr">addressbook_pb2.Person.PhoneType.WORK</code><span>的值为2。</span></p>
<h3 id="standard-message-methods" data-text="Standard Message Methods"><span>标准消息方法</span><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p><span>每个消息类还包含许多其他方法，可用于检查或操作整个消息，包括：</span></p>
<ul>
<li><code dir="ltr">IsInitialized()</code><span>：检查是否已设置所有必填字段。</span></li>
<li><code dir="ltr">__str__()</code><span><span>：返回消息的可读形式，对于调试特别有用。</span><span>（通常以</span></span><code dir="ltr">str(message)</code><span><span>或</span><span>调用</span></span><code dir="ltr">print message</code><span>。）</span></li>
<li><code dir="ltr">CopyFrom(other_msg)</code><span>：使用给定消息的值覆盖消息。</span></li>
<li><code dir="ltr">Clear()</code><span>：将所有元素清除为空状态。</span></li>
</ul>
<p><span>这些方法实现</span><code dir="ltr">Message</code><span><span>接口。</span><span>有关更多信息，请参见的</span></span><a href="https://googleapis.dev/python/protobuf/latest/google/protobuf/message.html#google.protobuf.message.Message" rel="noopener"><span><span>完整API文档</span></span><code dir="ltr">Message</code></a><span>。</span></p>
<h3 id="parsing-and-serialization" data-text="Parsing and Serialization"><span>解析和序列化</span><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<p><span>最后，每个协议缓冲区类都有使用协议缓冲区</span><a href="https://developers.google.com/protocol-buffers/docs/encoding" rel="noopener">二进制格式</a><span><span>写入和读取所选类型的消息的方法</span><span>。</span><span>这些包括：</span></span></p>
<ul>
<li><code dir="ltr">SerializeToString()</code><span><span>：序列化消息并以字符串形式返回。</span><span>注意字节是二进制的，不是文本；</span><span>我们仅将</span></span><code dir="ltr">str</code><span>类型用作方便的容器。</span></li>
<li><code dir="ltr">ParseFromString(data)</code><span>：解析给定字符串中的消息。</span></li>
</ul>
<p><span><span>这些只是为解析和序列化提供的几个选项。</span><span>同样，请参阅</span></span><a href="https://googleapis.dev/python/protobuf/latest/google/protobuf/message.html#google.protobuf.message.Message" rel="noopener"><code dir="ltr">Message</code><span><span>API参考</span></span></a><span>以获取完整列表。</span></p>
<p class="caution">协议缓冲区和面向对象的设计<span><span>协议缓冲区类基本上是愚蠢的数据持有者（如C中的结构）。</span><span>他们没有在对象模型中成为优秀的一等公民。</span><span>如果要向生成的类添加更丰富的行为，最好的方法是将生成的协议缓冲区类包装在特定于应用程序的类中。</span><span>如果您无法控制</span></span><code dir="ltr">.proto</code><span><span>文件</span><span>的设计，则包装协议缓冲区也是一个好主意</span><span>（例如，如果您要重用另一个项目中的文件）。</span><span>在这种情况下，您可以使用包装器类来设计一个更适合您的应用程序独特环境的接口：隐藏一些数据和方法，公开便利函数等。</span></span>您永远不应通过从它们继承来向生成的类添加行为<span><span>。</span><span>这将破坏内部机制，无论如何都不是一个好的面向对象的实践。</span></span></p>
<h2 id="writing-a-message" data-text="Writing A Message"><span>写一条消息</span><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p><span><span>现在，让我们尝试使用协议缓冲区类。</span><span>您希望地址簿应用程序能够做的第一件事是将个人详细信息写入地址簿文件。</span><span>为此，您需要创建并填充协议缓冲区类的实例，然后将它们写入输出流。</span></span></p>
<p><span>这是一个程序，它</span><code dir="ltr">AddressBook</code><span><span>从文件中</span><span>读取一个</span><span>，</span></span><code dir="ltr">Person</code><span><span>然后根据用户输入向其中</span><span>添加一个新</span></span><code dir="ltr">AddressBook</code><span><span>文件，然后再次</span><span>将新</span><span>文件</span><span>写</span><span>回到文件中。</span><span>突出显示直接调用或引用协议编译器生成的代码的部分。</span></span></p>
<div class="devsite-code-buttons-container">&nbsp;
<div class="cnblogs_Highlighter sh-gutter">
<div><div id="highlighter_108993" class="syntaxhighlighter  csharp"><div class="toolbar"><span><a href="https://www.cnblogs.com/a00ium/p/14128887.html#" class="toolbar_item command_help help">?</a></span></div><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div><div class="line number16 index15 alt1">16</div><div class="line number17 index16 alt2">17</div><div class="line number18 index17 alt1">18</div><div class="line number19 index18 alt2">19</div><div class="line number20 index19 alt1">20</div><div class="line number21 index20 alt2">21</div><div class="line number22 index21 alt1">22</div><div class="line number23 index22 alt2">23</div><div class="line number24 index23 alt1">24</div><div class="line number25 index24 alt2">25</div><div class="line number26 index25 alt1">26</div><div class="line number27 index26 alt2">27</div><div class="line number28 index27 alt1">28</div><div class="line number29 index28 alt2">29</div><div class="line number30 index29 alt1">30</div><div class="line number31 index30 alt2">31</div><div class="line number32 index31 alt1">32</div><div class="line number33 index32 alt2">33</div><div class="line number34 index33 alt1">34</div><div class="line number35 index34 alt2">35</div><div class="line number36 index35 alt1">36</div><div class="line number37 index36 alt2">37</div><div class="line number38 index37 alt1">38</div><div class="line number39 index38 alt2">39</div><div class="line number40 index39 alt1">40</div><div class="line number41 index40 alt2">41</div><div class="line number42 index41 alt1">42</div><div class="line number43 index42 alt2">43</div><div class="line number44 index43 alt1">44</div><div class="line number45 index44 alt2">45</div><div class="line number46 index45 alt1">46</div><div class="line number47 index46 alt2">47</div><div class="line number48 index47 alt1">48</div><div class="line number49 index48 alt2">49</div><div class="line number50 index49 alt1">50</div><div class="line number51 index50 alt2">51</div><div class="line number52 index51 alt1">52</div><div class="line number53 index52 alt2">53</div><div class="line number54 index53 alt1">54</div><div class="line number55 index54 alt2">55</div><div class="line number56 index55 alt1">56</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp preprocessor">#! /usr/bin/python</code></div><div class="line number2 index1 alt1">&nbsp;</div><div class="line number3 index2 alt2"><code class="csharp plain">import addressbook_pb2</code></div><div class="line number4 index3 alt1"><code class="csharp plain">import sys</code></div><div class="line number5 index4 alt2">&nbsp;</div><div class="line number6 index5 alt1"><code class="csharp preprocessor"># This function fills in a Person message based on user input.</code></div><div class="line number7 index6 alt2"><code class="csharp plain">def PromptForAddress(person):</code></div><div class="line number8 index7 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">person.id = </code><code class="csharp keyword">int</code><code class="csharp plain">(raw_input(</code><code class="csharp string">"Enter person ID number: "</code><code class="csharp plain">))</code></div><div class="line number9 index8 alt2"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">person.name = raw_input(</code><code class="csharp string">"Enter name: "</code><code class="csharp plain">)</code></div><div class="line number10 index9 alt1">&nbsp;</div><div class="line number11 index10 alt2"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">email = raw_input(</code><code class="csharp string">"Enter email address (blank for none): "</code><code class="csharp plain">)</code></div><div class="line number12 index11 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp keyword">if</code> <code class="csharp plain">email != </code><code class="csharp string">""</code><code class="csharp plain">:</code></div><div class="line number13 index12 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">person.email = email</code></div><div class="line number14 index13 alt1">&nbsp;</div><div class="line number15 index14 alt2"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp keyword">while</code> <code class="csharp plain">True:</code></div><div class="line number16 index15 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">number = raw_input(</code><code class="csharp string">"Enter a phone number (or leave blank to finish): "</code><code class="csharp plain">)</code></div><div class="line number17 index16 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">if</code> <code class="csharp plain">number == </code><code class="csharp string">""</code><code class="csharp plain">:</code></div><div class="line number18 index17 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">break</code></div><div class="line number19 index18 alt2">&nbsp;</div><div class="line number20 index19 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">phone_number = person.phones.add()</code></div><div class="line number21 index20 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">phone_number.number = number</code></div><div class="line number22 index21 alt1">&nbsp;</div><div class="line number23 index22 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">type = raw_input(</code><code class="csharp string">"Is this a mobile, home, or work phone? "</code><code class="csharp plain">)</code></div><div class="line number24 index23 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">if</code> <code class="csharp plain">type == </code><code class="csharp string">"mobile"</code><code class="csharp plain">:</code></div><div class="line number25 index24 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">phone_number.type = addressbook_pb2.Person.PhoneType.MOBILE</code></div><div class="line number26 index25 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">elif type == </code><code class="csharp string">"home"</code><code class="csharp plain">:</code></div><div class="line number27 index26 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">phone_number.type = addressbook_pb2.Person.PhoneType.HOME</code></div><div class="line number28 index27 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">elif type == </code><code class="csharp string">"work"</code><code class="csharp plain">:</code></div><div class="line number29 index28 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">phone_number.type = addressbook_pb2.Person.PhoneType.WORK</code></div><div class="line number30 index29 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">else</code><code class="csharp plain">:</code></div><div class="line number31 index30 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">print </code><code class="csharp string">"Unknown phone type; leaving as default value."</code></div><div class="line number32 index31 alt1">&nbsp;</div><div class="line number33 index32 alt2"><code class="csharp preprocessor"># Main procedure:&nbsp; Reads the entire address book from a file,</code></div><div class="line number34 index33 alt1"><code class="csharp preprocessor">#&nbsp;&nbsp; adds one person based on user input, then writes it back out to the same</code></div><div class="line number35 index34 alt2"><code class="csharp preprocessor">#&nbsp;&nbsp; file.</code></div><div class="line number36 index35 alt1"><code class="csharp keyword">if</code> <code class="csharp plain">len(sys.argv) != 2:</code></div><div class="line number37 index36 alt2"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">print </code><code class="csharp string">"Usage:"</code><code class="csharp plain">, sys.argv[0], </code><code class="csharp string">"ADDRESS_BOOK_FILE"</code></div><div class="line number38 index37 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">sys.exit(-1)</code></div><div class="line number39 index38 alt2">&nbsp;</div><div class="line number40 index39 alt1"><code class="csharp plain">address_book = addressbook_pb2.AddressBook()</code></div><div class="line number41 index40 alt2">&nbsp;</div><div class="line number42 index41 alt1"><code class="csharp preprocessor"># Read the existing address book.</code></div><div class="line number43 index42 alt2"><code class="csharp keyword">try</code><code class="csharp plain">:</code></div><div class="line number44 index43 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">f = open(sys.argv[1], </code><code class="csharp string">"rb"</code><code class="csharp plain">)</code></div><div class="line number45 index44 alt2"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">address_book.ParseFromString(f.read())</code></div><div class="line number46 index45 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">f.close()</code></div><div class="line number47 index46 alt2"><code class="csharp plain">except IOError:</code></div><div class="line number48 index47 alt1"><code class="csharp spaces">&nbsp;&nbsp;</code><code class="csharp plain">print sys.argv[1] + </code><code class="csharp string">": Could not open file.&nbsp; Creating a new one."</code></div><div class="line number49 index48 alt2">&nbsp;</div><div class="line number50 index49 alt1"><code class="csharp preprocessor"># Add an address.</code></div><div class="line number51 index50 alt2"><code class="csharp plain">PromptForAddress(address_book.people.add())</code></div><div class="line number52 index51 alt1">&nbsp;</div><div class="line number53 index52 alt2"><code class="csharp preprocessor"># Write the new address book back to disk.</code></div><div class="line number54 index53 alt1"><code class="csharp plain">f = open(sys.argv[1], </code><code class="csharp string">"wb"</code><code class="csharp plain">)</code></div><div class="line number55 index54 alt2"><code class="csharp plain">f.write(address_book.SerializeToString())</code></div><div class="line number56 index55 alt1"><code class="csharp plain">f.close()</code></div></div></td></tr></tbody></table></div></div>
</div>
<p>　　</p>
<div class="devsite-article-body clearfix    ">
<h2 id="extending-a-protocol-buffer" data-text="Extending a Protocol Buffer"><span>扩展协议缓冲区</span><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p><span><span>在发布使用协议缓冲区的代码后早晚，您无疑会想要“改进”协议缓冲区的定义。</span><span>如果您希望新的缓冲区向后兼容，而旧的缓冲区向后兼容，而您几乎肯定希望这样做，那么您需要遵循一些规则。</span><span>在新版本的协议缓冲区中：</span></span></p>
<ul>
<li><span>您</span><em>不得</em><span>更改任何现有字段的标签号。</span></li>
<li><span>您</span><em>不得</em><span>添加或删除任何必填字段。</span></li>
<li><span>您</span><em>可以</em><span>删除可选字段或重复字段。</span></li>
<li><span>您</span><em>可以</em><span>添加新的可选或重复字段，但必须使用新的标签号（即，该协议缓冲区中从未使用过的标签号，甚至删除的字段也从未使用过）。</span></li>
</ul>
<p><span><span>（</span><span>这些规则</span><span>有</span></span><a href="https://developers.google.com/protocol-buffers/docs/proto#updating" rel="noopener">一些例外</a><span>，但很少使用。）</span></p>
<p><span><span>如果遵循这些规则，旧代码将愉快地读取新消息，而忽略任何新字段。</span><span>对于旧代码，已删除的可选字段将仅具有其默认值，而删除的重复字段将为空。</span><span>新代码还将透明地读取旧消息。</span><span>但是，请记住，新的可选字段将不会出现在旧消息中，因此您需要明确检查是否已使用设置了这些字段，或者需要使用来</span></span><code dir="ltr">has_</code><span>在</span><code dir="ltr">.proto</code><span><span>文件中</span><span>提供合理的默认值</span></span><code dir="ltr">[default = value]</code><span><span>标签编号之后。</span><span>如果未为可选元素指定默认值，则使用特定于类型的默认值：对于字符串，默认值为空字符串。</span><span>对于布尔值，默认值为false。</span><span>对于数字类型，默认值为零。</span><span>还要注意，如果添加了一个新的重复字段，则由于没有</span></span><code dir="ltr">has_</code><span><span>标记，因此</span><span>新代码将无法分辨它是空的（由新代码）还是根本没有设置（由旧代码）</span><span>。</span></span></p>
<h2 id="advanced-usage" data-text="Advanced Usage"><span>高级用法</span><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p><span><span>协议缓冲区的用途不只是简单的访问器和序列化。</span><span>请务必浏览</span></span><a href="https://googleapis.dev/python/protobuf/latest/" rel="noopener">Python API参考，</a><span>以了解您还可以使用它们做什么。</span></p>
<p><span>协议消息类提供的一项关键功能是</span><em>反射</em><span><span>。</span><span>您可以遍历消息的字段并操纵它们的值，而无需针对任何特定的消息类型编写代码。</span><span>使用反射的一种非常有用的方法是将协议消息与其他编码（例如XML或JSON）相互转换。</span><span>反射的一种更高级的用法可能是查找同一类型的两条消息之间的差异，或者开发一种“协议消息的正则表达式”，在其中您可以编写与某些消息内容匹配的表达式。</span><span>如果您发挥自己的想象力，可以将协议缓冲区应用于比最初预期的范围更广的问题！</span></span></p>
<p><span>反射是</span><a href="https://googleapis.dev/python/protobuf/latest/google/protobuf/message.html#google.protobuf.message.Message" rel="noopener"><code dir="ltr">Message</code><span><span>接口的</span></span></a><span><span>一部分</span><span>。</span></span></p>
</div>
<div class="devsite-thumb-rating">&nbsp;</div>
<div class="devsite-thumb-rating">源:https://developers.google.com/protocol-buffers/docs/pythontutorial</div>
</div>
<p>　</p>
&nbsp;</div>
<p>&nbsp;</p>
</div>
<div class="clear"></div>
<div id="blog_post_info_block" role="contentinfo">




    <div id="blog_post_info">
<div id="green_channel">
        <a href="javascript:void(0);" id="green_channel_digg" onclick="DiggIt(14128887,cb_blogId,1);green_channel_success(this,&#39;谢谢推荐！&#39;);">好文要顶</a>
        <a id="green_channel_follow" onclick="follow(&#39;c2038c93-19a8-de11-ba8f-001cf0cd104b&#39;);" href="javascript:void(0);">关注我</a>
    <a id="green_channel_favorite" onclick="AddToWz(cb_entryId);return false;" href="javascript:void(0);">收藏该文</a>
    <a id="green_channel_wechat" href="javascript:void(0);" onclick="shareManager.wechatShare()">微信分享</a>
</div>
<div id="author_profile">
    <div id="author_profile_info" class="author_profile_info">
            <a href="https://home.cnblogs.com/u/a00ium/" target="_blank"><img src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/20150630162125.png" class="author_avatar" alt=""></a>
        <div id="author_profile_detail" class="author_profile_info">
            <a href="https://home.cnblogs.com/u/a00ium/">DaisyLinux</a>
            <br>
            <a href="https://home.cnblogs.com/u/a00ium/followers/">粉丝 - <span class="follower-count">51</span></a>
            <a href="https://home.cnblogs.com/u/a00ium/followees/">关注 - <span class="following-count">2</span></a><br>
        </div>
    </div>
    <div class="clear"></div>
    <div id="author_profile_honor"></div>
    <div id="author_profile_follow" class="follow-tip">
                <a href="javascript:void(0);" onclick="follow(&#39;c2038c93-19a8-de11-ba8f-001cf0cd104b&#39;);return false;">+加关注</a>
    </div>
</div>
<div id="div_digg">
    <div class="diggit" onclick="votePost(14128887,&#39;Digg&#39;)">
        <span class="diggnum" id="digg_count">0</span>
    </div>
    <div class="buryit" onclick="votePost(14128887,&#39;Bury&#39;)">
        <span class="burynum" id="bury_count">0</span>
    </div>
    <div class="clear"></div>
    <div class="diggword" id="digg_tips">
    </div>
        <div id="vip_tip"><a class="tip" href="https://cnblogs.vip/" target="_blank">升级成为会员</a></div>
</div>

<script type="text/javascript">
    currentDiggType = 0;
</script>
</div>
    <div class="clear"></div>
    <div id="post_next_prev">

    <a href="https://www.cnblogs.com/a00ium/p/14078527.html" class="p_n_p_prefix">« </a> 上一篇：    <a href="https://www.cnblogs.com/a00ium/p/14078527.html" data-featured-image="" title="发布于 2020-12-03 11:19">属性访问、特性和修饰符</a>
    <br>
    <a href="https://www.cnblogs.com/a00ium/p/14128974.html" class="p_n_p_prefix">» </a> 下一篇：    <a href="https://www.cnblogs.com/a00ium/p/14128974.html" data-featured-image="" title="发布于 2020-12-13 16:24">Python的基本Protobuf指南(序列化数据)</a>

</div>
</div>
            </div>
            <div class="postDesc">posted @ 
<span id="post-date" data-last-update-days="1283.765081226684" data-date-created="BlogServer.Application.Dto.BlogPost.BlogPostDto" data-date-updated="2020-12-13 16:03" aria-expanded="false">2020-12-13 16:03</span>&nbsp;
<a href="https://www.cnblogs.com/a00ium">DaisyLinux</a>&nbsp;
阅读(<span id="post_view_count">516</span>)&nbsp;
评论(<span id="post_comment_count">0</span>)&nbsp;
<a href="https://i.cnblogs.com/EditPosts.aspx?postid=14128887" rel="nofollow">编辑</a>&nbsp;
<a href="javascript:void(0)" onclick="AddToWz(14128887);return false;">收藏</a>&nbsp;
<a href="javascript:void(0)" onclick="reportManager.report({ currentUserId: &#39;&#39;, targetType: &#39;blogPost&#39;, targetId: &#39;14128887&#39;, targetLink: &#39;https://www.cnblogs.com/a00ium/p/14128887.html&#39;, title: &#39;协议缓冲区基础：Python&#39; })">举报</a>
</div>
        </div>
	    
	    
    </div><!--end: topics 文章、评论容器-->
</div>
<script>
    var cb_entryId = 14128887, cb_entryCreatedDate = '2020-12-13 16:03', cb_postType = 1, cb_postTitle = '协议缓冲区基础：Python';
    var allowComments = true, cb_blogId = 233489, cb_blogApp = 'a00ium', cb_blogUserGuid = 'c2038c93-19a8-de11-ba8f-001cf0cd104b';
    mermaidRender.render()
    markdown_highlight()
    zoomManager.apply("#cnblogs_post_body img:not(.code_img_closed):not(.code_img_opened)");    
</script>
<a id="!comments"></a>
<div id="blog-comments-placeholder"></div>
<div id="comment_form" class="commentform">
    <a name="commentform"></a>
    <div id="divCommentShow"></div>
    <div id="comment_nav">
            <a class="comment-nav-left forpc" href="https://cnblogs.vip/" target="_blank">会员力量，点亮园子希望</a>
        <div class="comment-nav-right">
            <span id="span_refresh_tips"></span><a href="https://www.cnblogs.com/a00ium/p/14128887.html#" onclick="return RefreshPage();">刷新页面</a><a href="https://www.cnblogs.com/a00ium/p/14128887.html#top">返回顶部</a>
        </div>
    </div>
    <div id="comment_form_container"><div class="login_tips">
    登录后才能查看或发表评论，立即 <a rel="nofollow" href="javascript:void(0);" class="underline" onclick="return account.login(&#39;!comments&#39;);">登录</a> 或者
    <a href="https://www.cnblogs.com/">逛逛</a> 博客园首页
</div>
</div>
    <div class="ad_text_commentbox" id="ad_text_under_commentbox"></div>
        <div id="cnblogs_ch"><a href="https://click.ctyun.cn/?track=source_bokeyuan-medium_cps-content_se1133006" target="_blank" onclick="gtag(&#39;event&#39;, &#39;click&#39;, {&#39;event_category&#39;: &#39;ad&#39;, &#39;event_label&#39;: &#39;T2-天翼云&#39;})">【推荐】天翼云-云享优惠·数智升级，2核4G云服务器82.8元/年</a><br><a href="https://www.cnblogs.com/cmt/p/18239927" target="_blank" onclick="gtag(&#39;event&#39;, &#39;click&#39;, {&#39;event_category&#39;: &#39;ad&#39;, &#39;event_label&#39;: &#39;T2-阿里云-通义灵码&#39;})">【推荐】「指间灵动，快码加编」：通义灵码，再次降临博客园</a><br><a href="https://www.cnblogs.com/cmt/p/18226431" target="_blank" onclick="gtag(&#39;event&#39;, &#39;click&#39;, {&#39;event_category&#39;: &#39;ad&#39;, &#39;event_label&#39;: &#39;T2-阿里云-征文&#39;})">【推荐】这场阿里云开发者社区有奖征文活动，期待您出文相助</a><br><a href="https://www.finclip.com/?channel=cnblog2024" target="_blank" onclick="gtag(&#39;event&#39;, &#39;click&#39;, {&#39;event_category&#39;: &#39;ad&#39;, &#39;event_label&#39;: &#39;T2-凡泰极客&#39;})">【推荐】凡泰极客：跨越技术“鸿”沟，小程序一键生成鸿蒙App</a><br><a href="https://click.aliyun.com/m/1000394160/" target="_blank" onclick="gtag(&#39;event&#39;, &#39;click&#39;, {&#39;event_category&#39;: &#39;ad&#39;, &#39;event_label&#39;: &#39;T2-阿里云-618&#39;})">【推荐】阿里云创新加速季，5亿补贴享不停，上云礼包抢先领</a><br></div>
    <div id="opt_under_post"></div>
        <div id="cnblogs_c1" class="under-post-card">
            <a href="https://cnblogs.vip/" rel="nofollow" target="_blank" onclick="countCreativeClicks(&#39;C1-博客园-会员&#39;)">
                <img src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/35695-20240328092537879-1189167464.jpg" onload="countCreativeImpressions(&#39;C1-博客园-会员&#39;)" alt="">
                <span id="c1_impression" style="display:none"></span>
            </a>
        </div>
    <div id="under_post_card1"><div class="under-post-card">
<b>编辑推荐：</b>
<br>

· <a href="https://www.cnblogs.com/thisiswhy/p/18252164" target="_blank">被这个叫做 at least once 的玩意坑麻了</a>
    <br>
· <a href="https://www.cnblogs.com/binlovetech/p/18253193" target="_blank">FinalReference 如何使 GC 过程变得拖拖拉拉</a>
    <br>
· <a href="https://www.cnblogs.com/wzh2010/p/18031212" target="_blank">千万级流量冲击下，如何保证极致性能</a>
    <br>
· <a href="https://www.cnblogs.com/coco1s/p/18243384" target="_blank">「现代 CSS」标准滚动条控制规范</a>
    <br>
· <a href="https://www.cnblogs.com/bt4girls/p/18241919" target="_blank">智能小车开发篇 - 低时延直播测试</a>
    <br>
</div></div>
    <div id="under_post_card2"><div class="itnews under-post-card">
    <b>阅读排行：</b>
    <br>
 ·          <a href="https://www.cnblogs.com/xueweihan/p/18253627" target="_blank">开源的网络瑞士军刀「GitHub 热点速览」</a>
        <br>
 ·          <a href="https://www.cnblogs.com/strick/p/18183911" target="_blank">带团队后的日常思考（十五）</a>
        <br>
 ·          <a href="https://www.cnblogs.com/thisiswhy/p/18252164" target="_blank">哎，被这个叫做at least once的玩意坑麻了。</a>
        <br>
 ·          <a href="https://www.cnblogs.com/huangxincheng/p/18253859" target="_blank">记一次 .NET某机械臂上位系统 卡死分析</a>
        <br>
 ·          <a href="https://www.cnblogs.com/binlovetech/p/18253193" target="_blank">FinalReference 如何使 GC 过程变得拖拖拉拉</a>
        <br>
</div></div>
    <div id="HistoryToday" class="under-post-card"></div>
    <script type="text/javascript">
        var commentManager = new blogCommentManager();
        commentManager.renderComments(0);
        fixPostBody();
        window.footnoteTipManager.generateFootnoteTips();

            window.tocManager.displayDisableTocTips = false;
            window.tocManager.generateToc();
            
                setTimeout(function() { countViews(cb_blogId, cb_entryId); }, 50);
            
            deliverT2();
            deliverC1C2();
            loadNewsAndKb();
            
                LoadPostCategoriesTags(cb_blogId, cb_entryId);
            
            LoadPostInfoBlock(cb_blogId, cb_entryId, cb_blogApp, cb_blogUserGuid);
            GetPrevNextPost(cb_entryId, cb_blogId, cb_entryCreatedDate, cb_postType);
            loadOptUnderPost();
            GetHistoryToday(cb_blogId, cb_blogApp, cb_entryCreatedDate);
                </script>
</div>

	</div><!--end: forFlow -->
	</div><!--end: mainContent 主体内容容器-->
	<div id="sideBar">
		<div id="sideBarMain">
			<div id="sidebar_news" class="newsItem">
    <h3 class="catListTitle">公告</h3>
<div id="blog-news">    
    <div id="sidebar_news_content">
<div id="profile_block">
    昵称：
    <a href="https://home.cnblogs.com/u/a00ium/">
        DaisyLinux
    </a>
    <br>
    园龄：
    <a href="https://home.cnblogs.com/u/a00ium/" title="入园时间：2009-09-23">
        14年8个月
    </a>
    <br>
    粉丝：
    <a class="follower-count" href="https://home.cnblogs.com/u/a00ium/followers/">
        51
    </a>
    <br>
    关注：
    <a class="folowing-count" href="https://home.cnblogs.com/u/a00ium/followees/">
        2
    </a>
    <div id="p_b_follow" class="follow-tip">
<a href="javascript:void(0)" onclick="follow(&#39;c2038c93-19a8-de11-ba8f-001cf0cd104b&#39;)">+加关注</a></div>
    <script>getFollowStatus('c2038c93-19a8-de11-ba8f-001cf0cd104b');</script>
</div>
</div>
</div>
<script>loadBlogNews();</script>

 
</div>
<div id="sidebar_c3"></div>
			<div id="blog-calendar" style="">

<table id="blogCalendar" class="Cal" cellspacing="0" cellpadding="0" title="Calendar" border="0">
    <tbody>
        <tr>
            <td colspan="7">
                <table class="CalTitle" cellspacing="0" border="0">
                    <tbody>
                        <tr>
                            <td class="CalNextPrev">
                                <a href="javascript:void(0);" onclick="loadBlogCalendar(&#39;2024/05/19&#39;); return false;">&lt;</a>
                            </td>
                            <td align="center">2024年6月</td>
                            <td align="right" class="CalNextPrev">
                                <a href="javascript:void(0);" onclick="loadBlogCalendar(&#39;2024/07/19&#39;); return false;">&gt;</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    <tr>
        <th class="CalDayHeader" align="center" abbr="日" scope="col">日</th>
        <th class="CalDayHeader" align="center" abbr="一" scope="col">一</th>
        <th class="CalDayHeader" align="center" abbr="二" scope="col">二</th>
        <th class="CalDayHeader" align="center" abbr="三" scope="col">三</th>
        <th class="CalDayHeader" align="center" abbr="四" scope="col">四</th>
        <th class="CalDayHeader" align="center" abbr="五" scope="col">五</th>
        <th class="CalDayHeader" align="center" abbr="六" scope="col">六</th>
    </tr>
            <tr>
                            <td class="CalOtherMonthDay" align="center">26</td>
                            <td class="CalOtherMonthDay" align="center">27</td>
                            <td class="CalOtherMonthDay" align="center">28</td>
                            <td class="CalOtherMonthDay" align="center">29</td>
                            <td class="CalOtherMonthDay" align="center">30</td>
                            <td class="CalOtherMonthDay" align="center">31</td>
                    <td class="CalWeekendDay" align="center">
                        1
                    </td>
            </tr>
                <tr>
                        <td class="CalWeekendDay" align="center">
                            2
                        </td>
                            <td class="" align="center">
                                3
                            </td>
                            <td class="" align="center">
                                4
                            </td>
                            <td class="" align="center">
                                5
                            </td>
                            <td class="" align="center">
                                6
                            </td>
                            <td class="" align="center">
                                7
                            </td>
                        <td class="CalWeekendDay" align="center">
                            8
                        </td>
                </tr>
                <tr>
                        <td class="CalWeekendDay" align="center">
                            9
                        </td>
                            <td class="" align="center">
                                10
                            </td>
                            <td class="" align="center">
                                11
                            </td>
                            <td class="" align="center">
                                12
                            </td>
                            <td class="" align="center">
                                13
                            </td>
                            <td class="" align="center">
                                14
                            </td>
                        <td class="CalWeekendDay" align="center">
                            15
                        </td>
                </tr>
                <tr>
                        <td class="CalWeekendDay" align="center">
                            16
                        </td>
                            <td class="" align="center">
                                17
                            </td>
                            <td class="" align="center">
                                18
                            </td>
                            <td class="CalTodayDay" align="center">
                                19
                            </td>
                            <td class="" align="center">
                                20
                            </td>
                            <td class="" align="center">
                                21
                            </td>
                        <td class="CalWeekendDay" align="center">
                            22
                        </td>
                </tr>
                <tr>
                        <td class="CalWeekendDay" align="center">
                            23
                        </td>
                            <td class="" align="center">
                                24
                            </td>
                            <td class="" align="center">
                                25
                            </td>
                            <td class="" align="center">
                                26
                            </td>
                            <td class="" align="center">
                                27
                            </td>
                            <td class="" align="center">
                                28
                            </td>
                        <td class="CalWeekendDay" align="center">
                            29
                        </td>
                </tr>
                <tr>
                        <td class="CalWeekendDay" align="center">
                            30
                        </td>
                            <td class="CalOtherMonthDay" align="center">
                                1
                            </td>
                            <td class="CalOtherMonthDay" align="center">
                                2
                            </td>
                            <td class="CalOtherMonthDay" align="center">
                                3
                            </td>
                            <td class="CalOtherMonthDay" align="center">
                                4
                            </td>
                            <td class="CalOtherMonthDay" align="center">
                                5
                            </td>
                        <td class="CalOtherMonthDay" align="center">
                            6
                        </td>
                </tr>
    </tbody>
</table></div><script>loadBlogDefaultCalendar();</script>			
			<div id="leftcontentcontainer">
				<div id="blog-sidecolumn"><!-- 搜索 -->
<div id="sidebar_search" class="sidebar-block">
    <div class="mySearch my-search">
        <h3 class="catListTitle">搜索</h3>
        <div id="sidebar_search_box">
            <div id="widget_my_zzk" class="div_my_zzk">
                <input type="text" id="q" onkeydown="return zzk_go_enter(event);" class="input_my_zzk">&nbsp;<input onclick="zzk_go()" type="button" value="找找看" id="btnZzk" class="btn_my_zzk">
            </div>
            
        </div>
    </div>
</div>

<!-- 常用链接 -->
<div id="sidebar_shortcut" class="sidebar-block"><div class="catListLink">
<h3 class="catListTitle">
常用链接
</h3>
<ul>
    <li><a href="https://www.cnblogs.com/a00ium/p/" title="我的博客的随笔列表">我的随笔</a></li>
<li><a href="https://www.cnblogs.com/a00ium/MyComments.html" title="我的发表过的评论列表">我的评论</a></li>
<li><a href="https://www.cnblogs.com/a00ium/OtherPosts.html" title="我评论过的随笔列表">我的参与</a></li>
<li><a href="https://www.cnblogs.com/a00ium/comments" title="我的博客的评论列表">最新评论</a></li>
<li><a href="https://www.cnblogs.com/a00ium/tag/" title="我的博客的标签列表">我的标签</a></li>

</ul>
</div>

</div>

<!-- 最新随笔 -->


<!-- 我的标签 -->
<div id="sidebar_toptags" class="sidebar-block"></div>

<!-- 积分与排名 -->


<!-- 随笔分类、随笔档案、文章分类、新闻分类、相册、链接 -->
<div id="sidebar_categories">

    <div id="sidebar_postarchive" class="catListPostArchive sidebar-block">
        <h3 class="catListTitle">
            
随笔档案


        </h3>

        <ul>

                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2024/05" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2024年5月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2024/04" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2024年4月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2024/01" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2024年1月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2023/10" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2023年10月(3)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2023/08" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2023年8月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2023/04" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2023年4月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2023/01" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2023年1月(3)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2022/12" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2022年12月(2)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2022/11" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2022年11月(4)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2022/10" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2022年10月(2)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2022/09" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2022年9月(2)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2022/08" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2022年8月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2022/05" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2022年5月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2022/04" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2022年4月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="true" style="display: block">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2022/03" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2022年3月(5)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2022/01" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2022年1月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2021/12" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2021年12月(2)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2021/11" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2021年11月(7)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2021/10" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2021年10月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2021/09" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2021年9月(4)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2021/08" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2021年8月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2021/07" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2021年7月(3)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2021/06" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2021年6月(4)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2021/05" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2021年5月(3)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2021/04" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2021年4月(2)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2021/02" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2021年2月(8)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2021/01" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2021年1月(2)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2020/12" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2020年12月(20)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2020/11" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2020年11月(13)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2020/10" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2020年10月(33)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2020/09" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2020年9月(7)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2020/08" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2020年8月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2020/07" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2020年7月(7)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2020/06" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2020年6月(5)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2020/02" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2020年2月(2)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2019/10" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2019年10月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2019/07" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2019年7月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2019/06" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2019年6月(2)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2019/05" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2019年5月(58)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2019/04" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2019年4月(1)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2019/03" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2019年3月(128)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2019/02" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2019年2月(105)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2019/01" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2019年1月(34)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2018/06" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2018年6月(2)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2017/07" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2017年7月(2)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2017/03" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2017年3月(4)</a>
 
                </li>                
                <li data-category-list-item-visible="false" style="display: none">
                    
<a href="https://www.cnblogs.com/a00ium/p/archive/2017/01" style="--cnb-category-item-link-indent-size: calc(0 * 1em)" class="category-item-link" rel="" target="">2017年1月(1)</a>
 
                </li>                
            <li>
                <a href="javascript:void(0)" onclick="sideColumnManager.loadMore(this)">更多</a>
            </li>
        </ul>


    </div>    
</div>

<!-- 最新评论 -->
<!-- 阅读排行榜 -->
<div id="sidebar_topviewedposts" class="sidebar-block"><div class="catListView">
    <h3 class="catListTitle">
        <a href="https://www.cnblogs.com/a00ium/most-viewed" class="sidebar-card-title-a">
    阅读排行榜
</a>

    </h3>
    <div id="TopViewPostsBlock">
        <ul style="word-break:break-all">
                    <li>
                        <a href="https://www.cnblogs.com/a00ium/p/13874909.html">
                            1. 在Python-Pandas中循环或遍历数据框的所有或某些列(26795)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/a00ium/p/14128974.html">
                            2. Python的基本Protobuf指南(序列化数据)(21558)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/a00ium/p/10867331.html">
                            3. linux shell 获取文件夹全文绝对路径(17265)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/a00ium/p/10360494.html">
                            4. jmeter如何设置全局变量以及调用方法(15712)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/a00ium/p/13875119.html">
                            5. Python | 查找给定字符串中字符的位置(15368)
                        </a>
                    </li>
        </ul>
    </div>
</div></div>

<!-- 评论排行榜 -->
<div id="sidebar_topcommentedposts" class="sidebar-block"><div class="catListFeedback">
    <h3 class="catListTitle">
        <a href="https://www.cnblogs.com/a00ium/most-commented" class="sidebar-card-title-a">评论排行榜</a>

    </h3>
    <div id="TopFeedbackPostsBlock">
        <ul style="word-break:break-all">
                    <li>
                        <a href="https://www.cnblogs.com/a00ium/p/14128974.html">
                            1. Python的基本Protobuf指南(序列化数据)(2)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/a00ium/p/10953106.html">
                            2. KAFKA 节点配置问题(2)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/a00ium/p/10849848.html">
                            3. JMeter进行Apache Kafka负载测试(2)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/a00ium/p/10412375.html">
                            4. JSON JSONPath(2)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/a00ium/p/14153083.html">
                            5. Go版本 gRPC快速入门(1)
                        </a>
                    </li>
        </ul>
    </div>
</div></div>

<!-- 推荐排行榜 -->
<div id="sidebar_topdiggedposts" class="sidebar-block">
<div id="topdigg_posts_wrap">
    <div class="catListView">
        <h3 class="catListTitle">
            <a href="https://www.cnblogs.com/a00ium/most-liked" class="sidebar-card-title-a">推荐排行榜</a>

        </h3>
        <div id="TopDiggPostsBlock">
            <ul style="word-break: break-all">
                        <li>
                            <a href="https://www.cnblogs.com/a00ium/p/14128974.html">
                                1. Python的基本Protobuf指南(序列化数据)(2)
                            </a>
                        </li>
                        <li>
                            <a href="https://www.cnblogs.com/a00ium/p/10462892.html">
                                2. JMETER结果分析(2)
                            </a>
                        </li>
                        <li>
                            <a href="https://www.cnblogs.com/a00ium/p/15337832.html">
                                3. 最全的Pycharm debug技巧，「建议收藏」(1)
                            </a>
                        </li>
                        <li>
                            <a href="https://www.cnblogs.com/a00ium/p/15039199.html">
                                4. pycharm自动生成文件注释和函数注释(1)
                            </a>
                        </li>
                        <li>
                            <a href="https://www.cnblogs.com/a00ium/p/14875138.html">
                                5. Python 中将 Pandas DataFrame 转换为 JSON？(1)
                            </a>
                        </li>
            </ul>
        </div>
    </div>
</div></div><div id="sidebar_recentcomments" class="sidebar-block"><div class="catListComment">
<h3 class="catListTitle"><a href="https://www.cnblogs.com/a00ium/comments" class="sidebar-card-title-a">最新评论</a></h3>
    <div class="RecentCommentBlock">
        <ul>
                <li class="recent_comment_title"><a href="https://www.cnblogs.com/a00ium/p/10360443.html">1. Re:Jmeter 自动化测试报告扩展(转 Todo 需要修正)</a></li>
                <li class="recent_comment_body"><p>您好，我套用你的xsl样式，但是只有一个接口的Response Data json化数据了，其他的接口的Response Data显示还是 Text<br>
希望得到您的知道</p>
</li>
                <li class="recent_comment_author">--有菜有多余的小测试</li>
                <li class="recent_comment_title"><a href="https://www.cnblogs.com/a00ium/p/11692273.html">2. Re:Kafka Consumer Lag Monitoring</a></li>
                <li class="recent_comment_body"><p>牛啊~</p>
</li>
                <li class="recent_comment_author">--规格严格-功夫到家</li>
                <li class="recent_comment_title"><a href="https://www.cnblogs.com/a00ium/p/14128974.html">3. Re:Python的基本Protobuf指南(序列化数据)</a></li>
                <li class="recent_comment_body">@Mos_x 序列化 完成用base64 encode一下, 解序列化的时候decode一下在用ParseFromString函数就可以了...</li>
                <li class="recent_comment_author">--喜又亻</li>
                <li class="recent_comment_title"><a href="https://www.cnblogs.com/a00ium/p/14128974.html">4. Re:Python的基本Protobuf指南(序列化数据)</a></li>
                <li class="recent_comment_body">作者您好，我有问题想问一下您， 3.Protobuf对象的序列化章节中，把序列化生成的人类可读的Protobuf消息后，该怎么反序列化呢？ParseFromString函数的话不行，因为它的输入得是二...</li>
                <li class="recent_comment_author">--Mos_x</li>
                <li class="recent_comment_title"><a href="https://www.cnblogs.com/a00ium/p/10360494.html">5. Re:jmeter如何设置全局变量以及调用方法</a></li>
                <li class="recent_comment_body"><p>${__P(newuserid,)}这样就可以了，newuserid后面加上一个英文的逗号，每次全局变量取值都是最新的</p>
</li>
                <li class="recent_comment_author">--上玄月-sunshine</li>
        </ul>
    </div>
</div>

</div>


</div>
                    <script>loadBlogSideColumn();</script>
			</div>			
		</div><!--end: sideBarMain -->
	</div><!--end: sideBar 侧边栏容器 -->
	<div class="clear"></div>
	</div><!--end: main -->
	<div class="clear"></div>
	<div id="footer">
		<!--done-->
Copyright © 2024 DaisyLinux
<br><span id="poweredby">Powered by .NET 8.0 on Kubernetes</span>



	</div><!--end: footer -->
</div><!--end: home 自定义的最大容器 -->



    

    <input type="hidden" id="antiforgery_token" value="CfDJ8ONv0caE5GtEh3YJ5j088kmfNNPItEN8CcA44BNE3IGSov_0wH3w9SIUszO0n6gAvsZ6QS08Yc9-4Ok81nQFo8LrCw0nvo1_5yLLXYRl4H1MscQAzjzHddzNmsOh2ann7pPhzM4cQUMWjnvJSAAGIgI">
    <script async="" src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/js"></script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag() { dataLayer.push(arguments); }
    gtag('js', new Date());
    gtag('config', 'G-M95P3TTWJZ');
</script>
<script defer="" src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/hm.js"></script>


<div style="z-index: 998; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); display: none; flex-direction: column; align-items: center; justify-content: center">
<div style="background: #fff;padding: 30px; margin: 30px; border-radius: 16px;">
  <div style="width: 200px; height: 200px; background: rgba(255, 255, 255, 0.8); position: absolute; top: -100px; right: -100px; border-radius: 100px"></div>
  <div style="text-align: center; font-size: 18px; margin-bottom: 10px;">点击右上角即可分享</div>
  <img src="./协议缓冲区基础：Python - DaisyLinux - 博客园_files/35695-20230906145857937-1471873834.gif" alt="微信分享提示">
</div>   
    </div></body></html>